require("SOD/model/DrawModel")

module SOD
  
  class DrawVolumeModel < DrawModel
    
    def initialize
      super
    end
    
    def draw(bar, active_model)
      super
      
      levelGroup = Sketchup.active_model.active_entities.add_group
      levelGroup.name = bar.name + "_Level1"
      levelEnts = levelGroup.entities
      
      levelGroup.move! @origin
      rotation = Geom::Transformation.rotation(@origin, [0, 0, 1], @angle)
      levelGroup.transform! rotation
      
      face = levelEnts.add_face([0, 0, 0], [@length, 0, 0], [@length, @width, 0], [0, @width, 0])
      face.reverse!
      face.pushpull(@overall_height)
      
      levelGroup.entities.each { |e| Plugin.sodLayers.putOnLayer(e) }
      
      @active_model.add levelGroup
      
      copyToStoreys(levelGroup, bar.name + "_Level")
      
    end
    
  end
  
end
